package com.lovo.view.dept;

import com.lovo.javafxComponent.LovoDate;
import com.lovo.javafxComponent.LovoTextArea;
import com.lovo.javafxComponent.LovoTitle;
import com.lovo.javafxComponent.LovoTxt;
import javafx.event.ActionEvent;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonBar.ButtonData;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Dialog;
import javafx.scene.layout.Pane;


/**
 * 添加部门信息
 * @author lovo
 *
 */
public class UpdateDeptDialog extends Dialog{
    /**内容容器*/
    private Pane container = new Pane();

    /**姓名文本框*/
    private LovoTxt nameTxt = new LovoTxt("部门名称", 80, 100,container);
    /**成立时间文本框*/
    private LovoDate bornDate = new LovoDate("成立时间", 80, 150,container);
    /**部门描述文本框*/
    private LovoTextArea deptArea = new LovoTextArea("部门描述", 80, 200,container);

    /**部门主面板*/
    private DeptPane deptPane;
    /**
     * 构造方法
     */
    public UpdateDeptDialog(DeptPane deptPane) {
        this.deptPane = deptPane;
        this.setTitle("修改部门");
        initComponent();
    }

    /**
     * 初始化组件
     */
    private void initComponent() {
        new LovoTitle("修改部门", -150, 30, container);
        container.setPrefSize(480, 350);
        this.getDialogPane().setContent(container);

        this.initInfo();


        ButtonType addButtonType = new ButtonType("修改", ButtonData.YES);
        this.getDialogPane().getButtonTypes().add(addButtonType);
        Button btnLogin = (Button) this.getDialogPane().lookupButton(addButtonType);

        btnLogin.addEventFilter(ActionEvent.ACTION, event -> {
            if(addDept() == false) {
                event.consume();
            }
        });

        ButtonType cancelButtonType = new ButtonType("取消", ButtonData.CANCEL_CLOSE);
        this.getDialogPane().getButtonTypes().add(cancelButtonType);

        this.showAndWait();
    }

    //------------------------

    /**
     * 添加
     * @return 添加是否成功
     */
    private boolean addDept() {
        if(check() == false){
            return false;
        }

        return true;
    }

    private boolean check(){
        return  true;
    }

    /**
     * 初始化下拉框信息
     */
    private void initInfo() {

    }



}
